/**
 * 
 */
package example;

import java.util.Calendar;

import sun.util.resources.CalendarData;
import sun.util.resources.CalendarData_lt;

import weibo4j.Status;
import weibo4j.Weibo;


/**
 * @author sina
 *
 */
public class UpdateStatus {

	/**
	 * 发布一条微博信息 
	 * @param args
	 */
	public static void main(String[] args) {
		System.setProperty("weibo4j.oauth.consumerKey",Weibo.CONSUMER_KEY);
    	System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
        try {
        	
        	//要发送的微博
            String statusText = "From Twigetor " + Calendar.getInstance().getTime();
        	
        	Weibo weibo = getWeibo(true,args);
        	Status status = weibo.updateStatus(statusText);
        	System.out.println(status.getId() + " : "+ status.getText()+"  "+status.getCreatedAt());
        	
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static Weibo getWeibo(boolean isOauth,String ... args) {
		Weibo weibo = new Weibo();
		if(isOauth) {//oauth验证方式 args[0]:访问的token；args[1]:访问的密匙
			weibo.setToken("995460685f6ea3265d550232eca1ef26","8a39d3ccca3739f773a9b9e2a2150097");
		}else {//用户登录方式
    		weibo.setUserId("371475640@qq.com");//用户名/ID
    		weibo.setPassword("twigetor");//密码
		}
		return weibo;
	}
}
